/** 
 * 项目名:shiro 
 * 文件名:RoleServlet.java 
 * 包名:com.spring.shiro.servlet 
 * 创建日期:2015年2月13日下午3:30:22 
 * 版权(c): ZTESOFT TECHNOLOGY CO.,LTD.Copyright 2012-2030.All rights reserved
 * 
 */

package com.spring.shiro.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

@WebServlet(name = "roleServlet", urlPatterns = "/role")
public class RoleServlet extends HttpServlet {

	private static final long serialVersionUID = 8122888888383034799L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		Subject subject = SecurityUtils.getSubject();
		subject.checkRole("admin");
		req.getRequestDispatcher("/WEB-INF/views/hasRole.jsp").forward(req, resp);
	}

}
